<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@page import="com.googlecode.contests_repo.core.users.UserManager"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Welcome!</title>
</head>
<body>

	<jsp:useBean id="user"
		class="com.googlecode.contests_repo.core.model.User" scope="request">
		<jsp:setProperty name="user" property="*" />
	</jsp:useBean>
	<%
	    if (request.getParameter("formSubmitted") != null)
	    {
			boolean isAuthorized = UserManager.isAuthorizedUser(
				user.getLogin(), user.getPassword());
			if (isAuthorized)
			{
			    session.setAttribute("username", user.getLogin());
				response.sendRedirect("Home.jsp");
	    	} else
			{
	%>
				<b style="color: red">Incorrect username or password!!!</b>
	<%
			}
	    }
	%>

	<form class="login" method="post">
		<span>Login:</span><br /> <label>User name:</label><br /> <input
			type="text" name="login" /><br /> <label>Password:</label><br /> <input
			type="password" name="password" /><br /> <input type="hidden"
			name="formSubmitted" value="true" /> <input type="submit"
			value="Login" />
	</form>
	<a href="Registration.jsp">Register</a>
</body>
</html>